import logging.handlers, os

logger = logging.getLogger()

logger.setLevel(logging.INFO)

logpath = "../log" + os.sep + "hm.log"
# 设置时间文件处理器
trfh = logging.handlers.TimedRotatingFileHandler(logpath, "s", 1, 3, "utf-8")

logger.addHandler(trfh)

fm = "%(asctime)s-%(levelname)s-[%(filename)s-%(funcName)s()-%(lineno)d]-%(message)s"
formatter = logging.Formatter(fm)

trfh.setFormatter(formatter)
logging.debug("debug")
logging.info("info")
logging.warning("warning")
logging.error("error")
logging.critical("critical")
